#!/bin/sh

sudo apt-get update
sudo apt-get install htop dstat build-essential linux-tools-common linux-tools-generic linux-tools-`uname -r`
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

cargo install flamegraph

git clone https://github.com/spacejam/sled.git
cd sled

cores=$(grep -c ^processor /proc/cpuinfo)
writers=(($cores / 5 + 1 ))
readers=$(( ($cores / 5 + 1) * 4 ))

cargo build --release --bin=stress2 --features=stress

# we use sudo here to get access to symbols
pushd benchmarks/stress2
cargo flamegraph --release -- --get=$readers --set=$writers
